<template>
  <div class="w-full overflow-hidden">
    <div class="mb-4 font-bold text-lg">人员信息</div>
    <el-row :gutter="20">
      <el-col
        :lg="8"
        :md="12"
        :sm="24"
        class="mb-4"
        v-for="(item, index) in dataList"
        :key="index"
      >
        <el-card shadow="hover">
          <div class="flex ">
            <img class="w-40 h-40" :src="item.photo" alt="" />
            <div class="ml-4 flex-grow">
              <div class="flex">
                <span>{{ item.name }}</span>
                <span class="ml-4">{{ item.totalScore }}分</span>
                <el-link
                  type="primary"
                  class="ml-auto"
                  @click="toStaffDetail(item)"
                  >查询详情</el-link
                >
              </div>
              <div class="mt-1">
                <el-tag
                  class="mr-2"
                  :type="item.expireStatus == -1 ? 'danger' : 'success'"
                >
                  <i
                    class="el-icon-s-release text-base"
                    v-if="item.expireStatus == -1"
                  ></i>
                  <i class="el-icon-s-claim text-base" v-else></i>
                  <span> 医师从业资格证 </span>
                  <i
                    class="el-icon-refresh text-base"
                    @click="handleRefresh(item)"
                  ></i>
                </el-tag>
                <el-tag>{{ item.staffType }}</el-tag>
              </div>
              <template v-if="item.dataType === 'physician'">
                <div class="font-bold my-1">医师多点执业</div>
                <div
                  class="flex justify-between text-sm"
                  v-for="v in item.locationList"
                >
                  <div>{{ v.locationName }}</div>
                  <div>
                    {{ v.recordRegistration === 1 ? "已" : "未" }}注册备案
                  </div>
                </div>
              </template>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {
  getEnterprisePersonListAPI,
  refreshQualificationAPI,
} from "@/api/zhangping/health-care/base-info.js";
export default {
  dicts: ["record_registration"],
  mixins: [],
  components: {},
  props: {},
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        creditCode: this.$route.query.creditCode,
      },
      total: 0,
      dataList: [],
    };
  },
  computed: {},
  watch: {},
  created() {
    this.getDataList();
  },
  mounted() {},
  methods: {
    handleRefresh(row) {
      const params = {
        id: row.id,
        dataType: row.dataType,
      };
      refreshQualificationAPI(params).then((res) => {
        console.log(res);
        if (res.code === 200) {
          this.$message.success("刷新成功");
          this.getDataList();
        }
      });
    },
    toStaffDetail(row) {
      console.log(row);

      if (row.dataType === "physician") {
        this.$router.push({
          path: "/health-care/doctor-detail",
          query: {
            id: row.id,
          },
        });

        return;
      }

      this.$router.push({
        path: "/health-care/nurse-detail",
        query: {
          id: row.id,
        },
      });
    },

    getDataList() {
      getEnterprisePersonListAPI(this.queryParams).then((res) => {
        if (res.code === 200) {
          this.total = res.total;
          this.dataList = res.rows;
        }
      });
    },
  },
};
</script>

<style scoped lang="scss"></style>
